from pathlib import Path
from openai import OpenAI

from http import HTTPStatus
import dashscope
from http import HTTPStatus
import dashscope
from pathlib import Path
from openai import OpenAI
import requests



import requests



file_url= 'https://gitee.com/jjyu-keji/experiment_pdf/raw/master/first/159890025.pdf'
print(file_url)

def call_with_messages():
    plugins = {'pdf_extracter': {}}  # choose the desired plugin(s).
    messages = [{'role': 'system', 'content': '你作为一个经验丰富的软件工程师'},
                {'role': 'user', 'content': [
                    {'text': '从10个维度出发，给这篇文章打分，重点考虑这篇文章的格式规范，结构清晰度、语言表达、信息完整性、逻辑连贯性及专业性等，每个10分共100分。'},
                    {'file': file_url}]
                 }]
    response = dashscope.Generation.call(
        api_key="sk-87c1cbb4dbcb4323a2e6785150439b14",
        model='qwen-turbo',
        messages=messages,
        result_format='message',  # set the result to be 'message' format.
        plugins=plugins,
    )
    if response.status_code == HTTPStatus.OK:
        print(response)
    else:
        print('Request id: %s, Status code: %s, error code: %s, error message: %s' % (
            response.request_id, response.status_code,
            response.code, response.message
        ))


if __name__ == '__main__':
    call_with_messages()
